package org.voidness.twittava.domain;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author void
 */
public class Status {

    private int id;

    private String text;

    private Date creationDate;

    private StatusUser user;
    
    public Status() {
        
    }
    
    public Status(int id, String text, Date creationDate, StatusUser user) {
        this.id = id;
        this.text = text;
        this.creationDate = creationDate;
        this.user = user;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setText(String text) {
        this.text = text;
    }

    public void setCreationDate(String date) {
        // Parse date
        // Sample: Tue Mar 13 00:12:41 +0000 2007
        // Format: EEE MMM dd hh:mm:ss Z yyyy
        SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd hh:mm:ss Z yyyy");
        try {
            this.creationDate = formatter.parse(date);
        } catch (ParseException ex) {
            //ex.printStackTrace();
            System.out.println("Error parsing date: " + date);
            this.creationDate = new Date();
        }
    }

    public void setUser(StatusUser user) {
        this.user = user;
    }
    
    public int getId() {
        return this.id;
    }

    public String getText() {
        return this.text;
    }

    public StatusUser getUser() {
        return this.user;
    }

    public Date getCreationDate() {
        return this.creationDate;
    }
    
}
